package com.yeban.javase.day02.test06;

/**
 * @Desc TODO
 * @Author yeban
 * @Date 2025/10/10
 *
 *   订单和货物，用户：
 *     1.一个订单会有多个货物（一对多的关系）,订单中一个方法（查看商品详情信息）
 *     2.货物是订单的属性
 *     3.订单与用户之间的关系，用户类中有下单的方法（用户姓名和订单号）
 *     4.测试类（调用执行下单方法和查看商品详情信息的方法）
 *   备注：用户User、订单Order、货物Goods
 */
public class Goods {

    private String name;
    private double price;
    private int num;
    private String description;

    public Goods() {
    }

    public Goods(String name, double price, int num, String description) {
        this.name = name;
        this.price = price;
        this.num = num;
        this.description = description;
    }

    // 显示信息
    public void displayInfo() {
        System.out.println("商品名称：" + name);
        System.out.println("商品价格：¥" + price);
        System.out.println("商品数量：" + num);
        System.out.println("商品描述：" + description);
        System.out.println("花费：¥" + (price * num));
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return price
     */
    public double getPrice() {
        return price;
    }

    /**
     * 设置
     * @param price
     */
    public void setPrice(double price) {
        this.price = price;
    }

    /**
     * 获取
     * @return num
     */
    public int getNum() {
        return num;
    }

    /**
     * 设置
     * @param num
     */
    public void setNum(int num) {
        this.num = num;
    }

    /**
     * 获取
     * @return description
     */
    public String getDescription() {
        return description;
    }

    /**
     * 设置
     * @param description
     */
    public void setDescription(String description) {
        this.description = description;
    }

    public String toString() {
        return "Goods{name = " + name + ", price = " + price + ", num = " + num + ", description = " + description + "}";
    }
}
